﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using System.Data.SqlClient;
using Webdiyer.WebControls.Mvc;
using hospital_management_system.ServiceReference1;

namespace hospital_management_system.Controllers
{
    public class OfficeController : Controller
    {
        //引用服务
        ServiceReference1.WebService1SoapClient client = new ServiceReference1.WebService1SoapClient();

        // GET: Office
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Off_AddPage(string name,int pageIndex = 1)
        {
            var s=client.SelectOff(name);
            return View(s.ToPagedList(pageIndex,4));
        }
        [HttpPost]
        public ActionResult Off_AddPages(string OffName, string OffMess)
        {
            ServiceReference1.T_Office m = new ServiceReference1.T_Office();
            m.Office_Name = OffName;
            m.Office_Mess = OffMess;
            int result = Convert.ToInt32(client.AddOffice(m));


            if (result > 0)
            {
                return Content("<script>alert('添加成功');location.href='/Office/Off_AddPage';</script>");
            }
            else
            {
                return Content("<script>alert('添加失败');location.href='/Office/Off_AddPage';</script>");

            }
        }
      
        public ActionResult DelOffice(int id)
        {
            int res = client.DelOffice(id);
            if (res > 0)
            {
                return Content("<script>alert('删除成功');location.href='/Office/Off_AddPage';</script>");
            }
            else
            {
                return Content("<script>alert('删除失败');location.href='/Office/Off_AddPage';</script>");

            }
        }
       
    }
}